package com.fzkj.socket;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.Socket;

public class Server1 {
    /**
     * 1.创建socket对象，指定端口
     * 2.
     */

    public static void main(String[] args)   {
        // 创建请求的socjet
        Socket s = null;
        BufferedWriter writer = null;
//        BufferedReader reader = null; // 从控制台读取数据
        try {
            s = new Socket("127.0.0.1", 9999);
            // 获得输出流
            OutputStream out = s.getOutputStream();
            writer = new BufferedWriter(new OutputStreamWriter(out));
//            reader = new BufferedReader(new InputStreamReader(System.in));
//            String line = null;
            String message = "[{'qid':'1','qtitle':'19-2+18','qanswer':'15','type':'简单'}]";
            while (true) {
                writer.write(message);
                writer.newLine();
                writer.flush();
                break;
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (writer != null) {
                    writer.close();
                }
                if (s != null) {
                    s.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
